package main

import (
	"fmt"
	"time"

	"github.com/user/simpleConfig_v1"
)

func main() {
	var listener simpleConfig_v1.ListenFunc = simpleConfig_v1.OnConfigChange
	filename := "config.ini"

	for {
		configuration, err := simpleConfig_v1.Watch(filename, listener)
		if err != nil {
			fmt.Println(err.Error())
		} else {
			fmt.Println(filename + "文件发生改变，改变后的配置信息如下：")
			//fmt.Println(configuration)
			for key, value := range configuration {
				fmt.Println(key, ":", value)
			}
			fmt.Println("")
		}

		time.Sleep(time.Duration(2) * time.Second)
	}

}
